insert overwrite table jms_dm.dm_tab_scan_piece_day_summary_dt partition(dt)
select scan_type_code,
       network_code,
       supplier_id,
       supplier_code,
       supplier_name,
       scan_type,
       network_name,
       network_type,
       pre_site_code,
       pre_site_name,
       next_site_code,
       next_site_name,
       shipment_no,
       shipment_name,
       sum(parts_cnt) parts_cnt,
       sum(packages_cnt) packages_cnt,
       sum(in_packages_cnt) in_packages_cnt,
       sum(scan_cnt) scan_cnt,
       sum(weight) weight,
       table_type,
       bz_type,
       md5(concat(nvl(uuid(),''),nvl(dt,''),nvl(pre_site_code,''),nvl(next_site_code,''),nvl(network_code,''),nvl(shipment_no,''))) one_id,
       date_time,
       dt
from jms_dm.dm_tab_scan_piece_summary_dt
where dt between date_add('{{ execution_date | cst_ds }}', -2 + 1) and '{{ execution_date | cst_ds }}'
group by 
       supplier_id,
       scan_type_code,
       network_code,
       supplier_code,
       supplier_name,
       scan_type,
       network_name,
       network_type,
       pre_site_code,
       pre_site_name,
       next_site_code,
       next_site_name,
       shipment_no,
       shipment_name,
       date_time,
       table_type,
       bz_type,
       dt 
        distribute by dt,abs(hash(one_id))%8;